package logic;

import data.User;
import ui.GlobalLogin;
import ui.UserCenterPanel;
import ui.UserDeposit;
import ui.UserTransfer;
import ui.UserUI;
import ui.UserWithdraw;

public class ACMethodUser {
UserCenterPanel usercenterPanel;
	UserUI userui;
	GlobalLogin globallogin;
	UserDeposit userdeposit;
	User currentUser;
	ACListUser aclistUser;
	UserWithdraw userwithdraw;
	UserTransfer usertransfer;
	
	 
	public ACMethodUser(UserUI userui, UserCenterPanel usercenterPanel) {
		this.userui=userui;
		this.usercenterPanel=usercenterPanel;
		this.globallogin = globallogin;
		this.userdeposit = usercenterPanel.userDeposit;
		this.aclistUser = userui.getAc();
		this.currentUser = aclistUser.getCurrentUser();
		this.userwithdraw = usercenterPanel.userWithdraw;
		this.usertransfer = usercenterPanel.userTransfer;
	}

	

	public void DepositButton() {
	usercenterPanel.show("userDeposit");
	
		
		
		}
	
	public void WithdrawButton() {
		usercenterPanel.show("userWithdraw");
	
		
}

	public void TransferButton() {
		usercenterPanel.show("userTransfer");
		
}
	
	public void HomeButton() {
		usercenterPanel.show("userDashboard");
		
}
	
	 
	
	 
	  
	public void deposit()
	
	{
	
		double depo; 
		
		try
		{
		   depo = Double.parseDouble(userdeposit.getAmountTextfield().getText());
		   if(depo > 0)
		   if (userdeposit.getDepoPasswordfield().getText().equals(currentUser.getPassword()))
				System.out.println("Deposit of " + depo +" DKK Confirmed");
		}
		catch (NumberFormatException nfe) { }
		
		
		
	}
		     
	public void withdraw()
	
	{
	
		double with; 
		
		try
		{
		    with = Double.parseDouble(userwithdraw.getAmountTextfield().getText());
		   if(with > 0)
		   if (userwithdraw.getWithPasswordfield().getText().equals(currentUser.getPassword()))
				System.out.println("Withdrawal of " + with +" DKK Confirmed");
		}
		catch (NumberFormatException nfe) { }
		
		
		
	}
		 public void transfer() {
			 double trans; 
			 
				try
				{
				   trans = Double.parseDouble(usertransfer.getTextfieldAmount().getText());
				   if(trans > 0 & usertransfer.found != null /*& usertransfer.found != currentUser.getFirstName() + currentUser.getLastName()*/)
				   if (usertransfer.getPasswordfieldConfirm().getText().equals(currentUser.getPassword()))
						System.out.println("Transferral of " + trans +" DKK for" + usertransfer.found +" Confirmed" );
				  
				}
				catch (NumberFormatException nfe) { }
			 
		 }
	
	
	public User getCurrentUser() {
		return currentUser;
	}

	public void setCurrentUser(User currentUser) {
		this.currentUser = currentUser;
	}
	
}
